﻿
using System;
using System.IO;
using System.Text;
namespace Logger
{


    public class Logger
    {
        private Logger() { }

        static string _Path;

        public static string Path
        {
            get
            {
                var path = Logger._Path + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                return path;
            }
        }

        public static void Write(string msg)
        {
            try
            {
                var fileName = DateTime.Now.ToString("HHmmss") + ".txt";
                var content = msg;
                File.WriteAllBytes(Logger.Path + fileName, Encoding.UTF8.GetBytes(content));
            }
            catch (Exception)
            {
            }

        }

        static Logger()
        {
            Logger._Path = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Log\\"; ;
        }

        public static void InitPath(string path)
        {
            Logger._Path = path;
        }
    }
}
